<?php
namespace Home\Controller;
use Think\Controller;

class UccarrymoneylogController extends  BaseController
{
	public function index(){
		
		$root = get_baseroot();
		
		
		$page = intval($GLOBALS['request']['page']);
		
		$user =  $GLOBALS['user_info'];
		$root['session_id'] = \es_session::id();
		$user_id  = intval($user['id']);
		if ($user_id >0){
            //require APP_ROOT_PATH.'app/Lib/uc_func.php';

            //$root['user_login_status'] = 1;
            $root['response_code'] = "1";

            if($page==0)
                $page = 1;
            $limit = (($page-1)*app_conf("PAGE_SIZE")).",".app_conf("PAGE_SIZE");
            $count = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."fuioupay_withdraw where user_id = ".$user_id." and `code` = 0000");
            $bank_info =array();
            $list = array();
            if($count > 0) {
                //查询银行名称及卡号
                $bank_info = $GLOBALS['db']->getRow("select ub.user_id as user_id, ub.bankcard as bankcard, b.`name` as name from ".DB_PREFIX."user_bank ub, ".DB_PREFIX."bank b  where user_id = ".$user_id." and ub.bank_id = b.id");
                //查询提现记录
                $list = $GLOBALS['db']->getAll("select user_id, amt, fee, create_time from ".DB_PREFIX."fuioupay_withdraw where user_id = ".$user_id." and `code` = 0000 order by create_time desc");

                //select fw.user_id as user_id,fw.amt as amt,fw.fee as fee, ub.bank_id, ub.bankcard as bankcard, b.name as bank_name from fanwe_fuioupay_withdraw fw LEFT JOIN fanwe_user_bank ub ON ub.user_id=fw.user_id LEFT JOIN fanwe_bank b ON b.id=ub.bank_id  where fw.user_id = 610 and fw.`code` = 0000 order by create_time desc limit 0,10
                //select user_id, amt, fee from fanwe_fuioupay_withdraw where user_id = 610 and `code` = 0000 order by create_time desc limit 0,10
                //select ub.user_id as user_id, ub.bankcard as bankcard, b.`name` as name from fanwe_user_bank ub LEFT JOIN fanwe_bank b ON ub.bank_id = b.id where user_id = 610
                //select ub.user_id as user_id, ub.bankcard as bankcard, b.`name` as name from fanwe_user_bank ub, fanwe_bank b  where user_id = 610 and ub.bank_id = b.id
            }
            $bank_info['bankcard'] = substr($bank_info['bankcard'], 0, 4)."********".substr($bank_info['bankcard'], -4);
            foreach ($list as $k => $v){
                $list[$k]['bankcard'] = $bank_info['bankcard'];
                $list[$k]['bankname'] = $bank_info['name'];
                $list[$k]['create_time'] = date("Y-m-d",$v['create_time']);
                $list[$k]['carry_rs'] = "成功";
            }
            //$root['bank_info'] = $bank_info;
            $root['item'] = $list;
            //$root['page'] = array("page"=>$page,"page_total"=>ceil($count/app_conf("PAGE_SIZE")),"page_size"=>app_conf("PAGE_SIZE"));
            $root['page'] = array("page"=>$page,"page_total"=>1,"page_size"=>app_conf("PAGE_SIZE"));
            $root['show_err'] ="操作成功";
		}else{
			$root['response_code'] = 0;
			$root['show_err'] ="未登录";
			$root['user_login_status'] = 0;
		}
		$root['program_title'] = "提现日志";
		//output($root);
        $root['act'] = CONTROLLER_NAME;
        $root['hide_back'] = 1 ;
        $this->assign('data',$root);
        $this->display();
	}
}
?>
